
//!============================================================================
//!<Interface> Vertex|Fragment
//!----------------------------------------------------------------------------

//!<Include> StdLight.sl

struct StdDirLight {
	// Light colors
	StdLightColor Colors;
	// Light direction
	vec3 Direction;
	// Half vector
	vec3 HalfVector;
};

// Compute directional light contribution
void ComputeLightContribution(inout StdLightColor colors, StdDirLight light, vec3 normal, float shininess);

//!----------------------------------------------------------------------------
//!<Source> Vertex|Fragment
//!----------------------------------------------------------------------------

//<Include> Interface

void ComputeLightContribution(inout StdLightColor colors, StdDirLight light, vec3 normal, float shininess)
{
	float NormalDotLightDir = max(0.0, dot(normal, normalize(vec3(light.Direction))));

	// Contribute with ambient
	colors.Ambient += light.Colors.Ambient;
	// Contribute with diffuse
	colors.Diffuse += light.Colors.Diffuse * NormalDotLightDir;
	// Contribute with specular
	if (NormalDotLightDir != 0.0) {
		float NormalDotLightHalf = max(0.0, dot(normal, vec3(light.HalfVector)));

		colors.Specular += light.Colors.Specular * pow(NormalDotLightHalf, shininess);
	}
}

//!============================================================================
//! Implementation notes
//!----------------------------------------------------------------------------
//!
//!----------------------------------------------------------------------------

